home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / nt / emacssrc.zip / EMACSSRC.TAR / emacs-19.17 / src / systty.h < prev    next >
C/C++ Source or Header  |  1993-07-26  |  10KB  |  371 lines

  1. /* systty.h - System-dependent definitions for terminals.
  2.    Copyright (C) 1993 Free Software Foundation, Inc.
  3.  
  4. This file is part of GNU Emacs.
  5.  
  6. GNU Emacs is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GNU Emacs is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GNU Emacs; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #ifdef HAVE_TERMIOS
  21. #define HAVE_TCATTR
  22. #endif
  23.  
  24. /* Include the proper files.  */
  25. #ifdef HAVE_TERMIO
  26. #ifdef __DGUX
  27. #include <sys/ioctl.h>
  28. #endif
  29. #ifndef NO_TERMIO
  30. #include <termio.h>
  31. #endif /* not NO_TERMIO */
  32. #include <fcntl.h>
  33. #else
  34. #ifdef HAVE_TERMIOS
  35. #if defined(_AIX) && defined(_I386)
  36. #include <termios.h>        /* termios.h needs to be before termio.h */
  37. #include <termio.h>
  38. #else
  39. #include <termio.h>
  40. #include <termios.h>
  41. #endif /* _AIX && _I386 */
  42. #include <fcntl.h>
  43. #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
  44. #ifndef VMS
  45. #ifdef WINDOWSNT
  46. #define NOMINMAX
  47. #include <windows.h>
  48. #else /* !WINDOWSNT */
  49. #include <sgtty.h>
  50. #endif /* !WINDOWSNT */
  51. #else /* VMS */
  52. #include <descrip.h>
  53. static struct iosb
  54. {
  55.   short status;
  56.   short offset;
  57.   short termlen;
  58.   short term;
  59. } input_iosb;
  60.  
  61. extern int waiting_for_ast;
  62. extern int stop_input;
  63. #if 0 /* VAX C doeasn't understand initializing declarations */
  64. extern int input_ef = 0;
  65. extern int timer_ef = 0;
  66. extern int process_ef = 0;
  67. #else
  68. extern int input_ef;
  69. extern int timer_ef;
  70. extern int process_ef;
  71. #endif
  72. extern int input_eflist;
  73. extern int timer_eflist;
  74.  
  75. static $DESCRIPTOR (input_dsc, "TT");
  76. static int terminator_mask[2] = { 0, 0 };
  77.  
  78. static struct sensemode {
  79.   short status;
  80.   unsigned char xmit_baud;
  81.   unsigned char rcv_baud;
  82.   unsigned char crfill;
  83.   unsigned char lffill;
  84.   unsigned char parity;
  85.   unsigned char unused;
  86.   char class;
  87.   char type;
  88.   short scr_wid;
  89.   unsigned long tt_char : 24, scr_len : 8;
  90.   unsigned long tt2_char;
  91. } sensemode_iosb;
  92. #endif /* VMS */
  93. #endif /* not HAVE_TERMIOS */
  94. #endif /* not HAVE_TERMIO */
  95.  
  96. #ifdef AIX
  97. /* Get files for keyboard remapping */
  98. #define HFNKEYS 2
  99. #include <sys/hft.h>
  100. #include <sys/devinfo.h>
  101. #endif
  102.  
  103. /* Get rid of LLITOUT in 4.1, since it is said to stimulate kernel bugs.  */
  104. #ifdef BSD4_1
  105. #undef LLITOUT
  106. #define LLITOUT 0
  107. #endif /* 4.1 */
  108.  
  109. #ifdef NEED_BSDTTY
  110. #include <sys/bsdtty.h>
  111. #endif 
  112.  
  113. #if defined (HPUX) && defined (HAVE_PTYS)
  114. #include <sys/ptyio.h>
  115. #endif
  116.   
  117. #ifdef AIX
  118. #include <sys/pty.h>
  119. #include <unistd.h>
  120. #endif /* AIX */
  121.  
  122. #ifdef IRIX4
  123. /* Get _getpty prototype */
  124. #include <unistd.h>
  125. #endif
  126.  
  127. #ifdef SYSV_PTYS
  128. #include <sys/types.h>
  129. #include <sys/tty.h>
  130. #ifdef titan
  131. #include <sys/ttyhw.h>
  132. #include <sys/stream.h>
  133. #endif
  134. #ifndef NO_PTY_H
  135. #include <sys/pty.h>
  136. #endif
  137. #endif
  138.  
  139. /* saka@pfu.fujitsu.co.JP writes:
  140.    FASYNC defined in this file. But, FASYNC don't working.
  141.    so no problem, because unrequest_sigio only need. */
  142. #if defined (pfa)
  143. #include <sys/file.h>
  144. #endif
  145.  
  146.  
  147. /* Special cases - inhibiting the use of certain features.  */
  148.  
  149. #ifdef APOLLO
  150. #undef TIOCSTART
  151. #endif
  152.  
  153. #ifdef XENIX
  154. #undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
  155. #endif
  156.  
  157. #ifdef BROKEN_TIOCGETC
  158. #undef TIOCGETC  /* Avoid confusing some conditionals that test this.  */
  159. #endif
  160.  
  161. /* UNIPLUS systems may have FIONREAD.  */
  162. #ifdef UNIPLUS
  163. #include <sys.ioctl.h>
  164. #endif
  165.  
  166. /* Allow m- file to inhibit use of FIONREAD.  */
  167. #ifdef BROKEN_FIONREAD
  168. #undef FIONREAD
  169. #undef ASYNC
  170. #endif
  171.  
  172. /* Interrupt input is not used if there is no FIONREAD.  */
  173. #ifndef FIONREAD
  174. #undef SIGIO
  175. #endif
  176.  
  177. /* On TERMIOS systems, the tcmumbleattr calls take care of these
  178.    parameters, and it's a bad idea to use them (on AIX, it makes the
  179.    tty hang for a long time).  */
  180. #if defined (TIOCGLTC) && !defined (HAVE_TERMIOS)
  181. #define HAVE_LTCHARS
  182. #endif
  183.  
  184. #if defined (TIOCGETC) && !defined (HAVE_TERMIOS)
  185. #define HAVE_TCHARS
  186. #endif
  187.  
  188.  
  189. /* Try to establish the correct character to disable terminal functions
  190.    in a system-independent manner.  Note that USG (at least) define
  191.    _POSIX_VDISABLE as 0!  */
  192.  
  193. #ifdef _POSIX_VDISABLE
  194. #define CDISABLE _POSIX_VDISABLE
  195. #else /* not _POSIX_VDISABLE */
  196. #ifdef CDEL
  197. #undef CDISABLE
  198. #define CDISABLE CDEL
  199. #else /* not CDEL */
  200. #define CDISABLE 255
  201. #endif /* not CDEL */
  202. #endif /* not _POSIX_VDISABLE */
  203.  
  204. /* Get the number of characters queued for output.  */
  205.  
  206. /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters
  207.    queued for output to the terminal FD in *SIZE, if FD is a tty.
  208.    Returns -1 if there was an error (i.e. FD is not a tty), 0
  209.    otherwise.  */
  210. #ifdef TIOCOUTQ
  211. #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TIOCOUTQ, (size)))
  212. #endif
  213.  
  214. #ifdef HAVE_TERMIO
  215. #ifdef TCOUTQ
  216. #undef EMACS_OUTQSIZE
  217. #define EMACS_OUTQSIZE(fd, size) (ioctl ((fd), TCOUTQ, (size)))
  218. #endif
  219. #endif
  220.  
  221.  
  222. /* Manipulate a terminal's current process group.  */
  223.  
  224. /* EMACS_HAVE_TTY_PGRP is true if we can get and set the tty's current
  225.    controlling process group.
  226.  
  227.    EMACS_GET_TTY_PGRP(int FD, int *PGID) sets *PGID the terminal FD's
  228.    current process group.  Return -1 if there is an error.
  229.  
  230.    EMACS_SET_TTY_PGRP(int FD, int *PGID) sets the terminal FD's
  231.    current process group to *PGID.  Return -1 if there is an error.  */
  232.  
  233. #ifdef HPUX
  234. /* HPUX tty process group stuff doesn't work, says the anonymous voice
  235.    from the past.  */
  236. #else
  237. #ifdef TIOCGPGRP
  238. #define EMACS_HAVE_TTY_PGRP
  239. #else
  240. #ifdef HAVE_TERMIOS
  241. #define EMACS_HAVE_TTY_PGRP
  242. #endif
  243. #endif
  244. #endif
  245.  
  246. #ifdef EMACS_HAVE_TTY_PGRP
  247.  
  248. #ifdef HAVE_TERMIOS
  249.  
  250. #define EMACS_GET_TTY_PGRP(fd, pgid) (*(pgid) = tcgetpgrp ((fd)))
  251. #define EMACS_SET_TTY_PGRP(fd, pgid) (tcsetpgrp ((fd), *(pgid)))
  252.  
  253. #else
  254. #ifdef TIOCSPGRP
  255.  
  256. #define EMACS_GET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCGPGRP, (pgid)))
  257. #define EMACS_SET_TTY_PGRP(fd, pgid) (ioctl ((fd), TIOCSPGRP, (pgid)))
  258.  
  259. #endif
  260. #endif
  261.  
  262. #else
  263.  
  264. /* Just ignore this for now and hope for the best */
  265. #define EMACS_GET_TTY_PGRP(fd, pgid) 0
  266. #define EMACS_SET_TTY_PGRP(fd, pgif) 0
  267.  
  268. #endif
  269.  
  270.  
  271. /* Manipulate a TTY's input/output processing parameters.  */
  272.  
  273. /* struct emacs_tty is a structure used to hold the current tty
  274.    parameters.  If the terminal has several structures describing its
  275.    state, for example a struct tchars, a struct sgttyb, a struct
  276.    tchars, a struct ltchars, and a struct pagechars, struct
  277.    emacs_tty should contain an element for each parameter struct
  278.    that Emacs may change.
  279.  
  280.    EMACS_GET_TTY (int FD, struct emacs_tty *P) stores the parameters
  281.    of the tty on FD in *P.  Return zero if all's well, or -1 if we ran
  282.    into an error we couldn't deal with.
  283.  
  284.    EMACS_SET_TTY (int FD, struct emacs_tty *P, int waitp)
  285.    sets the parameters of the tty on FD according to the contents of
  286.    *P.  If waitp is non-zero, we wait for all queued output to be
  287.    written before making the change; otherwise, we forget any queued
  288.    input and make the change immediately.
  289.    Return 0 if all went well, and -1 if anything failed.
  290.  
  291.    EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel
  292.    expands tabs to spaces upon output; in that case, there is no
  293.    advantage to using tabs over spaces.  */
  294.  
  295.  
  296. /* For each tty parameter structure that Emacs might want to save and restore,
  297.    - include an element for it in this structure, and
  298.    - extend the emacs_{get,set}_tty functions in sysdep.c to deal with the
  299.      new members.  */
  300.  
  301. struct emacs_tty {
  302.  
  303. /* There is always one of the following elements, so there is no need
  304.    for dummy get and set definitions.  */
  305. #ifdef HAVE_TCATTR
  306.   struct termios main;
  307. #else
  308. #ifdef HAVE_TERMIO
  309.   struct termio main;
  310. #else
  311. #ifdef VMS
  312.   struct sensemode main;
  313. #else
  314. #ifdef WINDOWSNT
  315.   /* Yikes! */
  316.   unsigned long main;
  317. #else
  318.   struct sgttyb main;
  319. #endif
  320. #endif
  321. #endif
  322. #endif
  323.  
  324. /* If we have TERMIOS, we don't need to do this - they're taken care of
  325.    by the tc*attr calls.  */
  326. #ifndef HAVE_TERMIOS
  327. #ifdef HAVE_LTCHARS
  328.   struct ltchars ltchars;
  329. #endif
  330.  
  331. #ifdef HAVE_TCHARS
  332.   struct tchars tchars;
  333.   int lmode;
  334. #endif
  335. #endif
  336. };
  337.  
  338. /* Define EMACS_GET_TTY and EMACS_SET_TTY,
  339.    the macros for reading and setting parts of `struct emacs_tty'.
  340.  
  341.    These got pretty unmanageable (huge macros are hard to debug), and
  342.    finally needed some code which couldn't be done as part of an
  343.    expression, so we moved them out to their own functions in sysdep.c.  */
  344. #define EMACS_GET_TTY(fd, p)        (emacs_get_tty ((fd), (p)))
  345. #define EMACS_SET_TTY(fd, p, waitp) (emacs_set_tty ((fd), (p), (waitp)))
  346.  
  347.  
  348. /* Define EMACS_TTY_TABS_OK.  */
  349.  
  350. #ifdef HAVE_TERMIOS
  351.  
  352. #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
  353.  
  354. #else /* not def HAVE_TERMIOS */
  355. #ifdef HAVE_TERMIO
  356.  
  357. #define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3)
  358.  
  359. #else /* neither HAVE_TERMIO nor HAVE_TERMIOS */
  360. #ifdef VMS
  361.  
  362. #define EMACS_TTY_TABS_OK(p) (((p)->main.tt_char & TT$M_MECHTAB) != 0)
  363.  
  364. #else
  365.  
  366. #define EMACS_TTY_TABS_OK(p) (((p)->main.sg_flags & XTABS) != XTABS)
  367.  
  368. #endif /* not def VMS */
  369. #endif /* not def HAVE_TERMIO */
  370. #endif /* not def HAVE_TERMIOS */
  371.